<template>
  <div id="online">
    <div class="title">设备在线</div>
    <div class="content">
      <div class="top">
        <div>
          <div class="text-title">设备在线率</div>
          <div class="text-value">{{ (deviceData.onlineNumber / deviceData.total * 100).toFixed(0) + '%' }}</div>
        </div>
      </div>
      <div class="bottom">
        <div>
          <div>
            <div class="text-title icon_5">接入总数</div>
            <div class="text-value">{{ deviceData.total }}</div>
          </div>
        </div>
        <div class="line"></div>
        <div>
          <div>
            <div class="text-title icon_6">在线</div>
            <div v-if="deviceData.onlineNumber > 0" style="cursor: pointer" @click="jumpPage('1')">
              <div class="text-value">{{
                deviceData.onlineNumber }}
                <i class="el-icon-arrow-right"></i>
              </div>

            </div>
            <div class="text-value" v-else>{{ deviceData.onlineNumber }}</div>
          </div>
        </div>
        <div class="line"></div>
        <div>
          <div>
            <div class="text-title icon_6">离线</div>
            <div v-if="deviceData.offlineNumber > 0" style="cursor: pointer" @click="jumpPage('0')">
              <div class="text-value">{{
                deviceData.offlineNumber }}
                <i class="el-icon-arrow-right"></i>
              </div>

            </div>
            <div class="text-value" v-else>{{ deviceData.offlineNumber }}</div>
          </div>
        </div>
      </div>
    </div>

  </div>
</template>


<script>
import device from '@/assets/images/device.png';
export default {
  props: {
    deviceData: {
      type: Object,
      default: {},
    }
  },
  
  data() {
    return {
      deviceImg: device,
    }
  },
  methods: {
    jumpPage(val) {
      this.$router.push({
        path: 'devices/allDevice',
        query: { onlineStatus: val },
      });
    },
  }

}
</script>

<style lang='scss' scoped>
@import './css/index.scss';

</style>